package org.wak.scene
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	
	import org.wak.action.actions.AdventureActions;;

	/**
	 * Gate Spot class used to jump from scene to scene. 
	 * 
	 */	
	public class GateSpot extends Sprite implements ISceneInteractable
	{
		
		// Destination scene id
		private var mDestinationSceneId:String = "";
		
		// Animation behaviour id after the jump.
		private var mBehaviourAnimId:String = "" ;
		
		// enabled flag of the gatespot.
		private var mEnabled:Boolean = true ;
		
		// Name of the destination to show in gui or text.
		private var mDestinationName:String = "" ;
		
		private var mGatespotId:String = "" ;
		
		public function GateSpot(pDef:IGateSpotDefinition)
		{
			super();
			
			this.x = pDef.position.x;
			this.y = pDef.position.y;
			
			
			mDestinationSceneId = pDef.sceneDestinationId ;
			
			var fAlpha:Number = 1;
			
			if(pDef.visible)
				fAlpha = 1 ;
			else
				fAlpha = 0 ;
			
			this.graphics.beginFill(0xFFFFFF,0);
			this.graphics.drawRect(0, 0, pDef.size.x, pDef.size.y);
			this.graphics.endFill() ;
			
			mEnabled = pDef.enabled ;
			mDestinationName = pDef.destinationName ;
			
			mGatespotId = pDef.gatespotId ;
		}
		
		/**
		 * Optional GateSpot id. 
		 * @return String with the gatespot id.
		 * 
		 */		
		public function get gatespotId():String
		{
			return mGatespotId ;
		}
		
		/**
		 * the Scene id where the player will go if he/she step on 
		 * the GateSpot. 
		 * @return Scene id of the destination scene. 
		 * 
		 */		
		public function get destinationSceneId():String
		{
			return mDestinationSceneId ;
		}
			
		
		/**
		 * Enabled flag of the GateSpot, allow or disallow the jump of the player.
		 * If this is disabled, it only works as receiving spot on the scene when
		 * the player jumps from another scene.
		 * @return jump enabled flag 
		 * 
		 */		
		public function get enabled():Boolean 
		{
			return mEnabled ;
		}
		
		public function set enabled(value:Boolean):void 
		{
			mEnabled = value;
		}
		
		public function get interactableId():String 
		{
			return "" ;
		}
		
		public function get interactionName():String 
		{
			return mDestinationName ;
		}
		
		public function get displayObject():DisplayObject 
		{
			return this ;
		}
		
		public function get baseline():int
		{
			return 0 ;
		}
		
		public function get interactionPointX():Number
		{
			return this.x + (this.width / 2) ;
		}
		
		public function get interactionPointY():Number
		{
			return this.y + (this.height / 2) ;
		}		
		
		public function get interactionBehaviour():String 
		{
			return "" ;
		}
		
		public function get unitaryUse():Boolean 
		{
			return false ;
		}
		
		
		public function get description():String 
		{
			return "" ;
		}
		
		public function get sceneId():String
		{
			return "" ;
		}
		
		public function get defaultAction():String 
		{
			return AdventureActions.ActionIdWalkTo ;
		}
		
	}
}